package org.feiye.studyday26;

public class ThreadState implements Runnable {
	// 线程的状态
	@Override
	public void run() {
		// 运行状态
		System.out.println("线程:" + Thread.currentThread().getName() + "处于运行状态！");
		try {
			Thread.sleep(5000);
			System.out.println("线程:" + Thread.currentThread().getName() + "处于阻塞状态！");
			throw new Exception();
		} catch (Exception e) {
			e.printStackTrace();
			System.err.println("线程:" + Thread.currentThread().getName() + "处于死亡状态！");
		}
	}

	public static void main(String[] args) {
		System.out.println("主线程：" + Thread.currentThread().getName() + "处于运行状态");
		Runnable r = new ThreadState();
		Thread t = new Thread(r, "ThreadState");
		System.out.println("线程:" + t.getName() + "处于创建状态！");
		t.start();
		System.out.println("线程:" + t.getName() + "处于就绪状态！");
	}
}
